package com.yanqu.road.server.cmd.activity.douluodalu;

import com.yanqu.road.entity.activity.douluodalu.log.DouLuoDaLuEventDefendData;
import com.yanqu.road.logic.pb.DouLuoDaLuPb;
import com.yanqu.road.pb.activity.douluodalu.DouLuoDaLuProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.douluodalu.DouLuoDaLuModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_DOU_LUO_DA_LU_EVENT_LOG_SYNC, desc = "同步一份森林事件公告作为个人日志")
public class DouLuoDaLuEventLogSyncCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DouLuoDaLuProto.DouLuoDaLuUploadEventNoticeMsg syncMsg = DouLuoDaLuProto.DouLuoDaLuUploadEventNoticeMsg.parseFrom(packet.getBytes());

        DouLuoDaLuEventDefendData defendData = DouLuoDaLuPb.paresDouLuoDaLuBattleReportData(syncMsg.getEventNotice(), player.getUserId(), syncMsg.getActivityId());
        defendData.setLogTime(System.currentTimeMillis());
        //加防守日志
        player.getModule(DouLuoDaLuModule.class).addEventDefendData(defendData);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
